package com.specialized.background.service.impl;

import java.util.List;
import com.specialized.common.core.utils.DateUtils;
import com.specialized.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.specialized.background.mapper.CouponTemplateMapper;
import com.specialized.background.domain.CouponTemplate;
import com.specialized.background.service.ICouponTemplateService;

/**
 * 代金卷模板Service业务层处理
 *
 * @author djh
 * @date 2024-07-30
 */
@Service
public class CouponTemplateServiceImpl implements ICouponTemplateService {
    @Autowired
    private CouponTemplateMapper couponTemplateMapper;
    @Autowired
    private RedisService redisService;

    /**
     * 查询代金卷模板
     *
     * @param couponId 代金卷模板主键
     * @return 代金卷模板
     */
    @Override
    public CouponTemplate selectCouponTemplateByCouponId(Long couponId) {
        return couponTemplateMapper.selectCouponTemplateByCouponId(couponId);
    }

    /**
     * 查询代金卷模板列表
     *
     * @param couponTemplate 代金卷模板
     * @return 代金卷模板
     */
    @Override
    public List<CouponTemplate> selectCouponTemplateList(CouponTemplate couponTemplate) {
        List<CouponTemplate> couponTemplates = couponTemplateMapper.selectCouponTemplateList(couponTemplate);
        redisService.setCacheList("couponTemplate",couponTemplates);
        List<CouponTemplate> cacheList = redisService.getCacheList("couponTemplate");
        return cacheList;
    }

    /**
     * 新增代金卷模板
     *
     * @param couponTemplate 代金卷模板
     * @return 结果
     */
    @Override
    public int insertCouponTemplate(CouponTemplate couponTemplate) {
        couponTemplate.setCreateTime(DateUtils.getNowDate());
        return couponTemplateMapper.insertCouponTemplate(couponTemplate);
    }

    /**
     * 修改代金卷模板
     *
     * @param couponTemplate 代金卷模板
     * @return 结果
     */
    @Override
    public int updateCouponTemplate(CouponTemplate couponTemplate) {
        couponTemplate.setUpdateTime(DateUtils.getNowDate());
        return couponTemplateMapper.updateCouponTemplate(couponTemplate);
    }

    /**
     * 批量删除代金卷模板
     *
     * @param couponIds 需要删除的代金卷模板主键
     * @return 结果
     */
    @Override
    public int deleteCouponTemplateByCouponIds(Long[] couponIds) {
        return couponTemplateMapper.deleteCouponTemplateByCouponIds(couponIds);
    }

    /**
     * 删除代金卷模板信息
     *
     * @param couponId 代金卷模板主键
     * @return 结果
     */
    @Override
    public int deleteCouponTemplateByCouponId(Long couponId) {
        return couponTemplateMapper.deleteCouponTemplateByCouponId(couponId);
    }






}
